using System.ComponentModel.DataAnnotations;
using FytSoa.Common.Enum;
using FytSoa.Domain.Hr;
using FytSoa.Domain.Sys;
using SqlSugar;

namespace FytSoa.Domain.Erp;

/// <summary>
/// erp-产品
/// </summary>
[SugarTable("erp_product")]
public class ErpProduct:Entity
{
    /// <summary>
    /// 产品编号
    /// </summary>
    [Required]
    [StringLength(50)]
    public string Number { get; set; }

    /// <summary>
    /// 产品名称
    /// </summary>
    [Required]
    [StringLength(100)]
    public string Name { get; set; }

    /// <summary>
    /// 供应商编号
    /// </summary>
    public long SupplierId { get; set; } = 0;
    
    /// <summary>
    /// 供应商
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(SupplierId))]
    public ErpSupplier Supplier { get; set; }

    /// <summary>
    /// 产品类别编号
    /// </summary>
    [Required]
    public long TypeId { get; set; }
    
    /// <summary>
    /// 产品类别
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(TypeId))]
    public SysCode Type { get; set; }

    /// <summary>
    /// 单位编号
    /// </summary>
    [Required]
    public long UnitId { get; set; }
    
    /// <summary>
    /// 产品单位
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(UnitId))]
    public SysCode Unit { get; set; }

    /// <summary>
    /// 市场价
    /// </summary>
    [Required]
    public decimal MarketPrice { get; set; }

    /// <summary>
    /// 成交价
    /// </summary>
    [Required]
    public decimal Price { get; set; }

    /// <summary>
    /// 产品图片
    /// </summary>
    [SugarColumn(IsJson = true)]
    public List<Image> Images { get; set; } = new();

    /// <summary>
    /// 负责人
    /// </summary>
    [Required]
    public long ChargePeopleId { get; set; }
    
    /// <summary>
    /// 负责人
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(ChargePeopleId))]
    public HrEmployee Employee { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    [Required]
    public bool Status { get; set; } = true;

    /// <summary>
    /// 预警值0为不限制
    /// </summary>
    [Required]
    public int MinCount { get; set; } = 0;
    
    /// <summary>
    /// 物料标签-枚举
    /// </summary>
    [Required]
    public ErpProductTagEnum ProductTag { get; set; } = ErpProductTagEnum.Materiel;

    /// <summary>
    /// 规格
    /// </summary>
    [SugarColumn(IsJson = true)]
    public List<Specs> Specifi { get; set; } = new();

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 更新人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 图片
    /// </summary>
    public class Image
    {
        public string Name { get; set; }
        
        public string Url { get; set; }
    }
    
    /// <summary>
    /// 规格
    /// </summary>
    public class Specs
    {
        public string Name { get; set; }
        
        public string Value { get; set; }
    }
}